package com.cbw.socket.tcp;


import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
//TCP客户端
public class MainClient {

    public static void main(String[] args) throws IOException {
     /*   //随机分配端口号
        Socket socket = new Socket("192.168.2.88", 8899);
        socket.getOutputStream().write("小武".getBytes("gb2312"));
        //自己设定端口号*/
        Socket socket1 = new Socket();//创建套接字对象
        socket1.bind( new InetSocketAddress(9999));//绑定本地端口
        socket1.connect(new InetSocketAddress("192.168.1.107", 8080));//建立Socket连接
        socket1.getOutputStream().write("萌萌".getBytes("gb2312"));//给服务器发送数据

    }
}
